import mountElement from "./mountElement";
import upDateNodeElement from './upDateNodeElement'
export default function createDOMElement(virtualDOM){
    let newElement = null
    if(virtualDOM.type==="text"){
        //文本节点
        newElement= document.createTextNode(virtualDOM.props.textContent)
    }else{
        // 元素节点
        newElement= document.createElement(virtualDOM.type)
        //添加元素属性
        upDateNodeElement(newElement,virtualDOM)
    }
    newElement._virtualDOM = virtualDOM
    virtualDOM.children.forEach(child => {
        mountElement(child,newElement)
    });
    return newElement
}